<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>修改</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link rel="stylesheet" type="text/css"
			href="css/style.css" />
	</head>

	<body>
		<div id="wrap">
			<div id="top_content">
					<div id="header">
						<div id="rightheader">
							<p>
								<span v-text="date"></span>
								<br />
								<a href="javascript:;" @click="logout">安全退出</a>
							</p>
						</div>
						<div id="topheader">
							<h1 id="title">
								<a href="/ems_vue/menu.html">返回功能页</a>
							</h1>
						</div>
						<div id="navigation">
						</div>
					</div>
				<div id="content">
					<p id="whereami">
					</p>
					<h1>
						更改基础工资:
					</h1>
					<form action="emplist.html" method="post">
						<table cellpadding="0" cellspacing="0" border="0"
							class="form_table">
							<tr>
								<td valign="middle" align="right">
									编号:
								</td>
								<td valign="middle" align="left">
									{{salary.e_id}}
								</td>
							</tr>
							<tr>
								<td valign="middle" align="right">
									姓名:
								</td>
								<td valign="middle" align="left">
									{{salary.name}}<!-- <input type="text" class="inputgri" v-model="salary.name" name="name" value="zhangshan"/> -->
								</td>
							</tr>
							<tr>
								<td valign="middle" align="right">
									基础工资:
								</td>
								<td valign="middle" align="left">
									<input type="text" class="inputgri" v-model="salary.basic" name="name" value="zhangshan"/>
								</td>
							</tr>
							<tr>
								<td valign="middle" align="right">
									加班津贴:
								</td>
								<td valign="middle" align="left">
									{{salary.overtime}}<!-- <input type="text" class="inputgri" v-model="salary.overtime" name="name" value="zhangshan"/> -->
								</td>
							</tr>
							<tr>
								<td valign="middle" align="right">
									其它津贴:
								</td>
								<td valign="middle" align="left">
									{{salary.allowance}}<!-- <input type="text" class="inputgri" v-model="salary.allowance" name="age" value="20"/> -->
								</td>
							</tr>
						</table>
						<p>
							<input type="button" @click="editSalary" class="button" value="修改" />
							<input type="button" @click="fanhui" class="button" value="取消" />
						</p>
					</form>
				</div>
			</div>
			<div id="footer">
				<div id="footer_bg">
					ranlen@cl.com
				</div>
			</div>
		</div>
	</body>
</html>
<script src="js/vue.js"></script>
<script src="js/axios.min.js"></script>
<script>
	var app = new Vue({
		el:"#wrap",
		data:{
			salary:{
				id:"1",
				e_id:"1",
                name:"2",
                basic:"3",
                overtime:"4",
                allowance:"5"
			},
			date:"2022/6"
		},
		methods:{
			logout(){
				axios.get("http://localhost:8989/ems_vue/user/logout").then(res=>{});
				sessionStorage.removeItem("token");
				location.href = "/ems_vue/login.html";
			},
			fanhui(){//返回
				location.href = "/ems_vue/salary.html";
			},
			editSalary(){
				let formData = new FormData();
				formData.append("id",this.salary.id);
				formData.append("e_id",this.salary.e_id);
				formData.append("name",this.salary.name);
				formData.append("basic",this.salary.basic);
				formData.append("overtime",this.salary.overtime);
				formData.append("allowance",this.salary.allowance);
				axios({
					method:"post",
					url:"http://localhost:8989/ems_vue/emp/updateSalary",
					data:formData,
					headers:{
						'content-type':'multipart/form-data'
					}
				}).then(res=>{
					console.log(res.data);
					if (res.data.state){
						location.href = "/ems_vue/salary.html";
					}else {
						alert(res.data.msg)
					}
				})
			}
		},
		created(){
			let start = location.href.lastIndexOf("=");
			let id  = location.href.substring(start+1);
			let _this = this;
			axios.get("http://localhost:8989/ems_vue/emp/findSalaryOne?id="+id).then(res=>{
				_this.salary = res.data;
			})
		}
	})
</script>